﻿// ---------------------------------------------------------------------
// Partial của lớp SSupervisor
//
// Nội dung:
//    + Các hàm gửi message Block trong các Phase
//
// Copyright (c) 2009 YugiOH
//
// Nguyễn Hữu Lê Trọng Tín      YM: ilu2009             ĐT: 0906520611 
// Võ Phước Hậu                 YM: phuochauspkt        ĐT: 0979202707
// ---------------------------------------------------------------------



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace ServerYuGi
{
    public partial class SSupervisor
    {
        /// <summary>
        /// Send Block Message cho 1 Player
        /// </summary>
        /// <param name="IDPlayer">ID Player nhận</param>
        public void SendMessage_TURN_MF1_BLOCK_ToID(int IDPlayer)
        {
            SPlayer player = LayPlayer(TurnManager.IDPlayerTrongLuot);
            List<byte> data = new List<byte>();

            
            data.Add(player.Block.DuocPhep_RaBaiNormal==true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_RaBaiSpecial == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_SetSpell == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_SetTrap == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_ActiveSpell == true ? (byte)1 : (byte)0);
            //DS Doi Trang Thai
            data.Add((byte)player.Block.DuocPhep_DoiTrangThai.Count);
            foreach (int item in player.Block.DuocPhep_DoiTrangThai)
            {
                data.Add((byte)item);
            }

            //ServerSocket.SendMessageToID(IDPlayer, YMSG.MF1_BLOCK, data.ToArray());
            Table.SendMessageToID(IDPlayer, YMSG.MF1_BLOCK, data.ToArray());
        }

        /// <summary>
        /// Send Block Message cho 1 Player
        /// </summary>
        /// <param name="IDPlayer">ID Player nhận</param>
        public void SendMessage_TURN_MF2_BLOCK_ToID(int IDPlayer)
        {
            SPlayer player = LayPlayer(TurnManager.IDPlayerTrongLuot);
            List<byte> data = new List<byte>();


            data.Add(player.Block.DuocPhep_RaBaiNormal == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_RaBaiSpecial == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_SetSpell == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_SetTrap == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_ActiveSpell == true ? (byte)1 : (byte)0);
            //DS Doi Trang Thai
            data.Add((byte)player.Block.DuocPhep_DoiTrangThai.Count);
            foreach (int item in player.Block.DuocPhep_DoiTrangThai)
            {
                data.Add((byte)item);
            }

            //ServerSocket.SendMessageToID(IDPlayer, YMSG.MF2_BLOCK, data.ToArray());
            Table.SendMessageToID(IDPlayer, YMSG.MF2_BLOCK, data.ToArray());
        }

        public void SendMessage_TURN_BF_BLOCK_ToID(int IDPlayer)
        {
            SPlayer player = LayPlayer(TurnManager.IDPlayerTrongLuot);
            List<byte> data = new List<byte>();

            data.Add(player.Block.DuocPhep_ActiveSpell == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_ActiveTrap == true ? (byte)1 : (byte)0);
            data.Add(player.Block.DuocPhep_TanCongTrucTiep == true ? (byte)1 : (byte)0);

            //DS Duoc Tan Cong
            data.Add((byte)player.Block.DuocPhep_TanCong.Count);
            foreach (int item in player.Block.DuocPhep_TanCong)
            {
                data.Add((byte)item);
            }
            //ServerSocket.SendMessageToID(IDPlayer, YMSG.BF_BLOCK, data.ToArray());
            Table.SendMessageToID(IDPlayer, YMSG.BF_BLOCK, data.ToArray());
        }
    }
}
